Skip to content

Remove names and code nothing uses, and review the kit's comments - #99

Merged
HalRiveria-Bot merged 11 commits into
mainfrom
change/remove-old-names
Dec 1, 2026
Merged

HalRiveria-Bot merged 11 commits into
mainfrom
change/remove-old-names

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Cleanup for the next major version: old names kept for compatibility, code nothing reaches, and a review of every comment in the kit.

Breaking

  • Initialize-ParallelKit no longer has -MaxConcurrentProcesses, which did nothing since 3.4, or ThreadPool in its result, which was always $true.
  • The dispatcher's -AbortPollCallback alias of -PollCallback is gone.

Code nothing used

  • Two C# overloads: PkStreamReadTask.Run(TextReader), which nothing called, and PkChildProcessJob.Assign(Process), which only the harness did. TypesVersion goes to 14.
  • The value the batch's own -JobFinalize returned: the dispatcher discards it.
  • Null checks whose value is never null: Receive-PkWorkerMessage's queue, Write-PkCallbackLoopWarning's context (every caller passes one) and Receive-PkCompletedHandle's result handler (it has a default).
  • Parameters the kit's own callbacks declared and never read.

Found by reading the whole file, by looking for functions, locals, parameters and C# members with no other reference, and by PSScriptAnalyzer. The "should be unreachable" checks in the dispatcher stay: a callback that overwrites a job's GroupKey does reach them.

Fixed

  • Loading the kit over a newer one's compiled types said an "older version" was loaded. It says "a different version" now.

Comments

  • Shorter where they ran long, reflowed where edits had left lines uneven, and without notes on how things used to work. One sat above the wrong code (Complete-PkProcess), one said a case couldn't happen that a second Assign reaches, one said the process functions use only .NET, and Receive-PkCompletedHandle had none. The kit's code with comments stripped differs from before only by the changes above.
  • Test-PkCancelRequested and Get-PkAbortTriggerLabel declare [OutputType()].

Tests

  • The removed parameter and alias are errors, and Initialize-ParallelKit's result has its four fields. Initialize-ParallelKit -MaxConcurrent is refused (it used to match -MaxConcurrentProcesses).
  • On the old code, 5.1 and 7 both fail the changed stale-types test, which wants "a different version".
  • Full harness: 713 passed on Windows PowerShell 5.1 and 713 passed on PowerShell 7.6.2, no skips. Testing/readme-examples/run.ps1 and Testing/hosts/check-host.ps1 -NoCtrlC pass on both.

🤖 Generated with Claude Code

HalRiveria and others added 11 commits December 1, 2026 16:12
Two of the batch's own closures called Complete-PkProcess and Write-PkMessage
by name. A .GetNewClosure() block only sees global functions, so a batch failed
with "'Complete-PkProcess' is not recognized" when the kit was loaded for one
module only. They're captured up front now, like the private helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A worker given the function (-SharedFunctionNames takes it) could set a handler
made in its own runspace, which the main thread then ran for every message.
Running another runspace's scriptblock can hang or crash PowerShell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It only looked for an abort after its first 200 ms wait, so a program that
finished sooner ran to the end and returned normally, and a slower one ran for
about 200 ms before it was killed. It now throws before starting the program,
unless -IgnoreAbort is given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… GetNewClosure

DelegateCast missed a scriptblock passed to .NET as ({ 1 }), { 1 }.GetNewClosure(),
[scriptblock]{ 1 } and the like, in the call or through a variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Invoke-PkRunspaceJobs is Invoke-PkRunspaceBatch, and 13 private functions lose
their plural names. -MaxConcurrent and -AbortTimeoutSeconds are the only names
on every engine: -MaxParallel and -DrainTimeoutSeconds are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Initialize-ParallelKit loses -MaxConcurrentProcesses and ThreadPool, and the
dispatcher its -AbortPollCallback alias. Code nothing reaches goes too. The
stale-types message says "a different version". Two functions declare their
output type. The comments are shorter and checked against the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	ParallelKit.Harness.ps1
#	ParallelKit.ps1
@HalRiveria-Bot
HalRiveria-Bot merged commit a1fea4d into main Dec 1, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the change/remove-old-names branch December 1, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants